<?php
defined('IN_PHPCMS') or exit('No permission resources.');
if(!defined('CACHE_MODEL_PATH')) define('CACHE_MODEL_PATH',PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);

pc_base::load_sys_class('model', '', 0);
class goods_type_model extends model {
	public function __construct() {
		$this->db_config = pc_base::load_config('database');
		$this->db_setting = 'default';
		$this->table_name = 'goods_type';
		parent::__construct();
	}

	/**
     * 取下拉分类
     */
	public function getTypes ($parentid)
	{
		$tree = pc_base::load_sys_class('tree');
        $result = $this->select(array("status"=>1,'siteid'=>get_siteid()));
        $array = array();
        foreach($result as $r) {
            $r['cname'] = L($r['cn_name']);
            $r['selected'] = $r['id'] == $parentid ? 'selected' : '';
            $array[] = $r;
        }
        $str  = "<option value='\$id' \$selected>\$spacer \$cname</option>";
        $tree->init($array);
        $categorys = $tree->get_tree(0, $str);
        return $categorys;
	}
}
?>